unit dlg_about;

//******************************************************************************
//  Unreal Translation Editor
//  copyright (c) Andrzej Oczkowicz <j3drek>
//  andrew_lz@poczta.fm, gg:5720464
//
//  license GNU GPL v2
//
//******************************************************************************

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Buttons, ComCtrls, futurama, ShellApi;

type
  Tdlg_about_ted = class(TForm)
    lblVer: TLabel;
    BitBtn1: TBitBtn;
    redAbout: TRichEdit;
    Image1: TImage;
    Bevel1: TBevel;
    Image2: TImage;
    Bevel2: TBevel;
    Panel1: TPanel;
    ImageLogo: TImage;
    lblText: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    Bevel3: TBevel;
    Button1: TButton;
    Button2: TButton;
    Panel2: TPanel;
    Image3: TImage;
    Animate1: TAnimate;
    Timer: TTimer;
    TrackBar: TTrackBar;
    Timer1: TTimer;
    pnRnd: TPanel;
    lblRnd: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure Label1Click(Sender: TObject);
    procedure Image3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure TimerTimer(Sender: TObject);
    procedure TrackBarChange(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure load_txt(const n:string);
  end;

var
  dlg_about_ted: Tdlg_about_ted;

implementation

{$R *.dfm}
{$R about.res}
{$R readme.res}
{$I TranslationEd.inc}

procedure Tdlg_about_ted.FormCreate(Sender: TObject);
begin
  Top  := 15;
  Left := 5;
  randomize();
  lblText.Caption := DateTimeToStr(now());
  lblVer.Caption := 'wersja ' + ver_FileVersion + ' z dnia ' + ver_DateString + #13 + ver_Comments;
  load_txt('LICENSE');
  futurama_init(Image2);
  futurama_show_random();
end;

procedure Tdlg_about_ted.Image2Click(Sender: TObject);
begin
  futurama_show_info();
end;

procedure Tdlg_about_ted.Label1Click(Sender: TObject);
begin
  ShellExecute(Handle,'open', pchar((Sender as TLabel).Caption), nil, nil, SW_SHOWMAXIMIZED);
end;

procedure Tdlg_about_ted.Image3Click(Sender: TObject);
begin
  Label1Click(Label1);
end;

procedure Tdlg_about_ted.Button1Click(Sender: TObject);
begin
  load_txt('LICENSE');
end;

procedure Tdlg_about_ted.load_txt(const n: string);
var
  r:TResourceStream;
begin
  r := TResourceStream.Create(hInstance, n, 'TEXT');
  try
    r.Position := 0;
    redAbout.Lines.LoadFromStream(r);
  finally
    r.Free;
  end;
end;

procedure Tdlg_about_ted.Button2Click(Sender: TObject);
begin
  load_txt('README');
end;

procedure Tdlg_about_ted.TimerTimer(Sender: TObject);
begin
  futurama_show_random();
end;

procedure Tdlg_about_ted.TrackBarChange(Sender: TObject);
begin
  Timer.Interval := TrackBar.Position * 1000;
  Timer.Enabled := TrackBar.Position  <> TrackBar.Max; 
end;

procedure Tdlg_about_ted.Timer1Timer(Sender: TObject);
begin
  lblRnd.Caption := IntToStr( random(99999) );
  lblRnd.Top := random(pnRnd.Height -15 );
  lblRnd.Left := random(pnRnd.Width - lblRnd.Width - 15);
  lblRnd.Font.Color :=  random($FFFFFFFE) ;
end;

end.
